/*
 * @Descripttion: 响应JSON
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-04-27 15:41:04
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-05-02 13:33:42
 */
class Response {
    msg = null;
    code = null;
    data = null;

    toString() {
        return JSON.stringify({
            msg: this.msg,
            code: this.code,
            data: this.data
        })
    }
}

/**
 * 失败
 */
class Fail extends Response {
    constructor(msg = 'fail', data, code = 500) {
        super()
        this.msg = msg;
        this.code = code;
        this.data = data;
    }
}

class Success extends Response {
    constructor(data, msg = 'success', code = 200) {
        super()
        this.msg = msg;
        this.code = code;
        this.data = data;
    }
}

module.exports = { Response, Fail, Success }